Open
Conversation
Currently we coerce all values into quoted Sass Strings. This PR coerces the JSON value into the appropriate Sass value type. If the value type cannot be determined we fallback to a quoted Sass String to avoid errors. This differs from [prior work][1] in that no attempt is made to mangle JSON arrays and maps into a JSON string value. [1]: pmowrer/node-sass-json-importer#5 Fixes #3
|
Really nice! Removes the need for any sanitization of inputs after grabbing them from the map. I was relying on Quick test and things look great. Input: {
"color": "#f00",
"size": "24px",
"font": "1.5em",
"darkColor": "darken(#f00, 15%)"
}@import "config.json";
$color: map-get($config, "color");
$size: map-get($config, "size");
$font: map-get($config, "font");
$darkColor: map-get($config, "darkColor");
body {
padding: $size + 2px;
color: lighten($color, 10%);
font-size: $font * 1.5;
background-color: $darkColor;
}Output body {
padding: 26px;
color: #ff3333;
font-size: 2.25em;
background-color: #b30000;
} |
|
@xzyfer The only thing I can think that's missing from this is handling booleans. Input {
"bool": false
}@import "config.json";
$bool: map-get($config, "bool");
body {
@if $bool {
padding: 0px;
} @else {
padding: 123px;
}
&:before {
content: $bool;
}
}Output body {
padding: 0px;
}
body:before {
content: "false";
}The |
Member
Author
|
Nice suggestions. I think that should be easy enough to do.
…On Fri., 14 Dec. 2018, 6:54 am Jon Clark ***@***.*** wrote:
@xzyfer <https://github.com/xzyfer> The only thing I can think that's
missing from this is handling booleans.
*Input*
{
"bool": false
}
@import "config.json";
$bool: map-get($config, "bool");
body {
@if $bool {
padding: 0px;
} @else {
padding: 123px;
}
&:before {
content: $bool;
}
}
*Output*
body {
padding: 0px;
}
body:before {
content: "false";
}
The @if statement is true since it's just being evaluated as a string.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAjZWNi7Cxd-P0xl_6C_uTH3OWuJdj2hks5u4rB8gaJpZM4VcccU>
.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently we coerce all values into quoted Sass Strings.
This PR coerces the JSON value into the appropriate Sass value type.
If the value type cannot be determined we fallback to a quoted
Sass String to avoid errors.
This differs from prior work in that no attempt is made to
mangle JSON arrays and maps into a JSON string value.
Fixes #3